<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script type="text/javascript">
		function dojobmakeemail(value, row, index) {
			var remove = "", makedemaildetail = "",write="";
			var savetoedit=row.emailId+',"'+row.reservename + '","' + row.copylist + '","' +row.emailTheme+ '","' +row.emailText+'"';
			makedemaildetail = "<a onclick='savedetail(" + row.emailId+ ")' class='easyui-linkbutton button-teal handle-btn'>邮件详情</a>";
			write = "<a onclick='savetowrite("+savetoedit+")' class='easyui-linkbutton button-blue handle-btn'>发送</a>";
			remove = "<a onclick='savedelete(" + row.emailId+ ")' class='easyui-linkbutton button-darkblue handle-btn'>删除</a>";
			return makedemaildetail +write+ remove;
		}
		/* 暂存箱删除窗口按钮方法 */
		function savedelete(emailId){
			$.post('savedelete',{data:emailId},function(){
				
			});	
			$("#savedemail-list").datagrid("load");
		}
		
		/* 暂存详情 */
		function savedetail(emailId){
			$("#savedetailinfo").datagrid({url: "savedetailif?emailid=" + emailId});
			$("#savedetailid").window("open");
		}
		
		/* 暂存邮件编辑窗口 */
		function savetowrite(emailId,reservename,copylist,emailTheme,emailText){
			$("#reservenames").text(reservename);
			$("#copylists").text(copylist);
			$("#themeas").textbox('setValue',emailTheme)
			$("#texts").textbox('setValue',emailText);
			$("#emailids").val(emailId);
			$("#saveforwrite").window("open");
		}
		
		/* 发送暂存邮件 */
		function saveforemail(){
			var emailtheme=$("#themeas").val();
			var emailtext=$("#texts").val();
			var emailid=$("#emailids").val();
			$.post('saveforemail',{emailid:emailid,emailtheme:emailtheme,emailtext:emailtext},function(){
				$.messager.alert('提示', '发送成功！', 'info'); 
				$("#saveforwrite").window('close');
				$("#savedemail-list").datagrid("load");
			});	
		}
		
		/* 保存暂存邮箱编辑 */
		function saveforsave(){
			var emailtheme=$("#themeas").val();
			var emailtext=$("#texts").val();
			var emailid=$("#emailids").val();
			$.post('saveforsavee',{emailid:emailid,emailtheme:emailtheme,emailtext:emailtext},function(){
				$.messager.alert('提示', '保存成功！', 'info'); 
				$("#saveforwrite").window('close');
				$("#savedemail-list").datagrid("load");
			});	
		}
	</script>
	<div class="easyui-layout" fit="true" >
		<!-- 暂存箱-->
		<div id="makedemail" style="width:100%;height:100%;">
	        <table id="savedemail-list" class="easyui-datagrid" style="height:100%;width:100%;"
		data-options="
				url:'to_savedemail',
				autoRowHeight:false,
				striped:true,
				pagination:true,
				rownumbers:true,
				singleSelect:true,
				fitColumns:true,
				remoteSort:false,
				pageList:[5,10]
		">
			<thead>
			<tr>
					<th data-options="field:'emailId',checkbox:true"></th> 
	            	<th style="width:8%;" align="center" data-options="field:'name'">发件人</th> 
	            	<th style="width:8%;" align="center" data-options="field:'reservename'">收件人</th>
	            	<th style="width:20%;" align="center" data-options="field:'startdate'">发件时间</th>
	            	<th style="width:30%;" align="center" data-options="field:'reservestate'">收件状态</th>  
	            	<th style="width:10%;" align="center" data-options="field:'copynum'">抄送数量</th>  	  
	            	<th style="width:24%;" align="center" data-options="field:'dojob',formatter:dojobmakeemail">操作</th> 
			</tr>
			</thead>
			</table>
		</div>
	</div>	
	
	<!-- 我的暂存详情窗口 -->
	<div id="savedetailid" class="easyui-window" title="暂存详情" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true, closed: true" style="width:400px;height:310px;padding:5px;">
        <div class="easyui-layout" data-options="fit:true">
            <table id="savedetailinfo" class="easyui-datagrid" style="height:100%;width:100%;"   
                data-options=" fitColumns:true,singleSelect:true,
                				autoRowHeight:true,singleSelect:true 
                " >   
                <thead>   
                    <tr style="border:1px solid white;height:100%;width:100%;">
                    	<th data-options="field:'name'" align="center"  style="width:20%;"></th>   
                        <th data-options="field:'value'" style="width:85%;"></th>                          
                    </tr>   
                </thead>   
            </table>
                 
            <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)" onclick="$('#savedetailid').window('close');">关闭</a>
            </div>
        </div>
    </div>
    
    <!-- 编辑暂存邮件窗口 -->
    <div id="saveforwrite" class="easyui-window" title="发送暂存" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true, closed: true" style="width:550px;height:450px;padding:5px;">
        <div class="easyui-layout" data-options="fit:true">
        	<!-- 存储邮件编号 -->
        	<input type="text" id="emailids" style="display:none;">
            <!-- 收件人 -->
            <div style="float:left;margin-top:5px;width:90%;">
            	<div style="float:left;">收件人:&nbsp;</div><div id="reservenames" style="float:left;"></div>
            </div>
            <!-- 抄送人 -->
            <div style="float:left;margin-top:5px;width:90%;">
            	<div style="float:left;">抄送人:&nbsp;</div><div id="copylists" style="float:left;"></div>
            </div>
            <!-- 主题 -->
            <div style="clear:both;margin-top:50px;">
            	主&nbsp;&nbsp;题:&nbsp;<input id="themeas" class="easyui-textbox" style="width:90%;border:1px solid #DADADA;">
            </div> 
            <!-- 内容  -->
            <div style="clear:both;margin-top:20px;">
            	<input id="texts" class="easyui-textbox" label="内&nbsp;&nbsp;&nbsp;容:" multiline="true"
            	style="width:96%;height:98%;border:1px solid #DADADA;">
            </div> 
               
            <div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
            	<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" href="javascript:void(0)" onclick="saveforemail()">发送</a>
            	<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true" href="javascript:void(0)" onclick="saveforsave()">保存</a>
                <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:void(0)" onclick="$('#saveforwrite').window('close');">关闭</a>
                
            </div>
        </div>
    </div>
</body>
</html>